package com.zzq.service.impl;

import com.zzq.domain.dto.SmilePointGoodsDTO;
import com.zzq.domain.entity.SmilePointGoods;
import com.zzq.domain.search.PointGoodsSearchParamet;
import com.zzq.mapper.SmilePointGoodsMapper;
import com.zzq.service.SmilePointGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzq.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 小布
 * @since 2023-10-31
 */
@Service
public class SmilePointGoodsServiceImpl extends ServiceImpl<SmilePointGoodsMapper, SmilePointGoods> implements SmilePointGoodsService {


    @Autowired
    SmilePointGoodsMapper pointGoodsMapper;
    @Override
    public List<SmilePointGoodsDTO> getPointGoodsDTOList(PointGoodsSearchParamet searchParamet) {
        return pointGoodsMapper.getPointGoodsDTOList(searchParamet);
    }

    @Override
    public SmilePointGoodsDTO getPointGoodsDTO(Long goodsId) {
        PointGoodsSearchParamet searchParamet=new PointGoodsSearchParamet();
        searchParamet.setGoodsId(goodsId);
        List<SmilePointGoodsDTO> pointGoodsDTOList = pointGoodsMapper.getPointGoodsDTOList(searchParamet);
        if (ObjectUtils.isListSole(pointGoodsDTOList)) {
            return pointGoodsDTOList.get(0);
        }
        return null;
    }
}
